package net.ezsteam;

import net.ezsteam.cons.EzSteam_Urls;
import net.ezsteam.service.EzSteam_Service_ServiceType;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Spinner;


public class EzSteam_ServiceType_Activity extends Activity {
	
	private String customerid="";
	private String user="";
	private String email="";
	private String password="";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ezsteam_service_type);
		
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			String cusid = extras.getString("cusid");
			String user = extras.getString("user");
			String email = extras.getString("email");
			String password = extras.getString("password");
			customerid  = cusid;
			this.user  = user;
			this.email  = email;
			this.password  = password;
		}

		Button btnsubmit = (Button) findViewById(R.id.btn_submit);
		Button btnlogout = (Button) findViewById(R.id.btn_logout);
		Button btnmyAppoinments = (Button) findViewById(R.id.btn_myAppoinments);
		Button btnmyprofile = (Button) findViewById(R.id.btn_myprofile);
		
		
		final Spinner type_spnr = (Spinner)findViewById(R.id.spn_servicetype);
		
		EzSteam_Service_ServiceType sstype = new EzSteam_Service_ServiceType(EzSteam_ServiceType_Activity.this,type_spnr);
        sstype.execute(EzSteam_Urls.GET_Service_Type);
		
        btnlogout.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
				Intent intent = new Intent(EzSteam_ServiceType_Activity.this,EzSteam_LoginActivity.class);
				startActivity(intent);
			}
		});

		btnsubmit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(EzSteam_ServiceType_Activity.this,EzSteam_StoreVisit_Activity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				Bundle bundle = new Bundle();
				bundle.putString("cusid", customerid);
				bundle.putString("type", ""+type_spnr.getSelectedItemPosition());
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});
		
		btnmyAppoinments.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(EzSteam_ServiceType_Activity.this,EzSteam_Appoinment_Activity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				Bundle bundle = new Bundle();
				bundle.putString("cusid", customerid);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});
		
		btnmyprofile.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(EzSteam_ServiceType_Activity.this,EzSteam_MyProfile_Activity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				Bundle bundle = new Bundle();
				bundle.putString("cusid", customerid);
				bundle.putString("user", user);
				bundle.putString("email", email);
				bundle.putString("password", password);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}


}
